package com.woniuxy.homeWork.service.impl;

import com.woniuxy.homeWork.commons.JDKProxy;
import com.woniuxy.homeWork.dao.UserMapper;
import com.woniuxy.homeWork.model.User;
import com.woniuxy.homeWork.service.UserService;
import com.woniuxy.homeWork.util.SqlSessionUtil;

import java.util.List;

/**
 * ClassName:UserServiceImpl
 * Package:com.woniuxy.homeWork.service.impl
 *
 * @date:2021/11/2 5:52 下午
 * @author: Tiangle
 */
public class UserServiceImpl implements UserService {
    UserMapper mapper = SqlSessionUtil.getMapper(UserMapper.class);
    @Override
    public boolean addUser(User user) {
//        UserMapper mapper = SqlSessionUtil.getMapper(UserMapper.class);
        int i = mapper.addUser(user);
        return i>0?true:false;
    }

    @Override
    public boolean updateUser(User user) {
        int i = mapper.updateUser(user);
        return i>0?true:false;
    }

    @Override
    public boolean deleteUser(Integer id) {
        int i = mapper.deleteUser(id);
        return i>0?true:false;
    }

    @Override
    public User getOne(Integer id) {
        User user = mapper.selectUserById(id);
        return user;
    }

    @Override
    public List<User> getAll() {
        return mapper.selectUsers();
    }
}
